package com.lzl.service.impl;

import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.lzl.bean.my_dev.Restaurant;
import com.lzl.common.Pager;
import com.lzl.dao.my_dev.write.RestaurantWriteDao;
import com.lzl.dao.my_dev.read.RestaurantReadDao;
import com.lzl.service.IRestaurantService;

/**
 * 描述：Restaurant 服务实现层
 * @author:cx
 * @version:1.0
 * @since:1.0
 * @createTime:2018-11-28 20:54:43
 */
@Service(value = "restaurantService")
public class RestaurantServiceImpl implements IRestaurantService{
	
	@Resource
    private RestaurantWriteDao restaurantWriteDao;

	@Resource
    private RestaurantReadDao restaurantReadDao;

    public Restaurant getById(Integer id) throws Exception {
        Restaurant restaurant = restaurantReadDao.getById(id);
        return restaurant;
    }
	
    public List<Restaurant> get(Map<String, Object> queryMap, Pager pager)throws Exception {
		if (pager != null) {
			if(pager.isGetCount()){
				pager.setRowsCount(restaurantReadDao.getCount(queryMap));
			}
            queryMap.put("start", pager.getStart());
            queryMap.put("size", pager.getPageSize());
        }
        List<Restaurant> restaurantList = restaurantReadDao.get(queryMap);
        return restaurantList;
    }

    public Boolean post(Restaurant restaurant) throws Exception {
        int result = restaurantWriteDao.post(restaurant);
        return result > 0 ;
    }

    public Boolean put(Restaurant restaurant) throws Exception {
        int result = restaurantWriteDao.put(restaurant);
        return result > 0 ;
    }

}
